<!--
 - $Id: sysCodeUpload.xhtml 16 2014-08-22 10:12:14Z ratking $
 -
 - Copyleft (C) 2014 RatKing. All wrongs reserved.
-->
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/layout/template.xhtml">

    <f:metadata>
        <f:event type="javax.faces.event.PreRenderViewEvent" listener="#{sysCodeUpload.beginConversation}"/>
    </f:metadata>

    <ui:define name="head">
        <style type="text/css">
            .ui-fileupload-browser .fileupload-buttonbar {
                display: none !important;
            }
        </style>
    </ui:define>

    <ui:define name="navigation">
        <p:breadCrumb>
            <p:menuitem value="首页" url="/index.xhtml"/>
            <p:menuitem value="系统管理" url="#"/>
            <p:menuitem value="代码管理" url="#"/>
            <p:menuitem value="批量导入" url="#"/>
        </p:breadCrumb>
    </ui:define>

    <ui:define name="helpInfo">
        <h:panelGrid>
            <h:outputText class="ui-icon icon-fugue-smiley" style="display: inline-block"/>
            批量导入系统代码～<br/>
            上传系统代码Excel文件，并导入数据库中；<br/>
            合作保险公司、代码类型、代码名称、代码值，这几列必须非空；<br/>
            如果多次导入相同的Excel文件，不应有副作用。<br/>
        </h:panelGrid>
    </ui:define>

    <ui:define name="content">
        <h:form id="sysCodeUploadForm" enctype="multipart/form-data">
            <p:panel header="批量导入系统代码">
                <h:panelGrid columns="2">
                    <p:outputLabel value="系统代码："
                                   title="在支持HTML5的浏览器里，你可以试试把上传的文件从资源管理器拖动到这里！"/>
                    <h:panelGroup>
                        <p:fileUpload id="uploadFile"
                                      fileUploadListener="#{sysCodeUpload.handleFileUpload}"
                                      mode="advanced"
                                      multiple="false"
                                      update="@form"
                                      sizeLimit="1048576"
                                      allowTypes="/(\.|\/)(xls)$/"
                                      auto="true"
                                      fileLimit="1"
                                      fileLimitMessage="只允许上传1个文件"
                                      label="选择文件"
                                      uploadLabel="上传"
                                      cancelLabel="取消"
                                      required="true"
                                      requiredMessage="请上传系统代码文件"
                                      invalidFileMessage="文件格式非法(必须是MS Excel 97-2003格式的.xls文件)"
                                      invalidSizeMessage="文件大小非法(不得大于1MB)"/>
                        <h:outputText id="uploadFileInfo"
                                      value="#{sysCodeUpload.uploadMsg}"
                                      title="已上传文件"
                                      rendered="#{not empty sysCodeUpload.uf}"/>
                    </h:panelGroup>
                </h:panelGrid>

                <f:facet name="footer">
                    <h:panelGrid columns="2">
                        <p:commandButton id="okButton"
                                         value="确定"
                                         action="#{sysCodeUpload.save()}"
                                         icon="icon-fugue-tick"
                                         ajax="false"
                                         disabled="#{empty sysCodeUpload.uf}"
                                         update="@form"/>

                        <p:commandButton id="cancelButton"
                                         value="取消"
                                         action="#{sysCodeUpload.cancel()}"
                                         icon="icon-fugue-cross"
                                         ajax="false"
                                         immediate="true"/>
                    </h:panelGrid>
                </f:facet>
            </p:panel>
        </h:form>
    </ui:define>
</ui:composition>
